<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改密码</title>
<script type="text/javascript" src="${staticResources}/js/ajax.js"></script>
<link type="text/css" href="${staticResources}/css/personalcenter.css" rel="stylesheet" />
<script type="text/javascript">
function changepassword()
{
	var password = document.getElementById("password").value;
	var newpassword = document.getElementById("newpassword").value;
	var newpassword2 = document.getElementById("newpassword2").value;
	var mode = "ajax";
	
	var params="password=" + encodeURIComponent(password);
	params+="&newpassword="+encodeURIComponent(newpassword);
	params+="&newpassword2="+encodeURIComponent(newpassword2);
	params+="&mode="+encodeURIComponent(mode);
	
	var checkid=document.getElementById("checkid");
	if(password.length==0) {
		checkid.innerHTML="<font color='red'> 旧密码不能为空！</font>";
		return;
	}
	if(newpassword.length==0) {
		checkid.innerHTML="<font color='red'> 新密码不能为空！</font>";
		return;
	}
	if(newpassword.length<6||newpassword.length>20) {
		checkid.innerHTML="<font color='red'> 新密码长度必须在6~20之间！</font>";
		return;
	}
	if(newpassword2.length==0) {
		checkid.innerHTML="<font color='red'> 确认密码不能为空！</font>";
		return;
	}
	if(newpassword != newpassword2) {
		checkid.innerHTML="<font color='red'> 两次输入的新密码不一致！</font>";
		return;
	}
	
	doAjax("${contextPath }/Account/ChangePassword"
			,params,function(rst){
	var rst=eval('(' +rst+ ')');
	if(rst.status == 0)
	{
		window.alert("密码修改成功！");
	}
	else 
	{
		window.alert(rst.message);
	} 
	});
}

</script>	
</head>
<body onload="iframeResizePipe()">

<iframe id="helpframe" src='' height='0' width='0' frameborder='0'></iframe>
<script type="text/javascript">
  function iframeResizePipe()
  {
     // What's the page height?
     var height = document.body.scrollHeight;

     // Going to 'pipe' the data to the parent through the helpframe..
     var pipe = document.getElementById('helpframe');

     // Cachebuster a precaution here to stop browser caching interfering
     pipe.src = '${contextPath}/framehelper.html?height='+height+'&cacheb='+Math.random();
  }
</script>

<div class="con">
  <div class="password">
    <div class="grey2" style=" font-weight:600"><b>修改密码</b></div>
    <div class="xgmm">
      <form method="post" action="${contextPath }/Account/ChangePassword" onsubmit="changepassword();return false;">
      <div class="clear"></div>
      <dl>
        <label>
        <dd>旧密码：</dd>
        <input type="password" style="width:200px; height:25px;" name="password" id="password" placeholder="旧密码" />
        </label>
      </dl>
      <div class="clear"></div>
      <dl>
        <label>
        <dd>新密码：</dd>
        <input type="password" style="width:200px; height:25px;" name="newpassword" id="newpassword" placeholder="新密码" />
        </label>
      </dl>
      <div class="clear"></div>
      <dl>
        <label>
        <dd>确认密码：</dd>
        <input type="password" style="width:200px; height:25px;" name="newpassword2" id="newpassword2" placeholder="确认密码" />
        </label>
      </dl>
      <div class="clear"></div>
      <div class="tijiao">
        <input type="image" style="" src="${staticResources}/image/submit.jpg" width="100" height="35"  class="button" name="" value=""/>
      </div>
      <div class="clear"></div>
      </form>
      <div id="checkid"></div>
    </div>
  </div>
</div>

</body>
</html>